#include "../ooc/inc/Object.h"
#include "inc/Fish.h"
#include "inc/Dog.h"
#include "inc/Car.h"

MLeakDef tMLeak;

int main()
{    
    
    MLeak_Init(&tMLeak);
    
    OOC_CLASS_INIT_FUNC_NAME(Object)();

   
    
    Object* obj = OOC_CTOR_NAME(Object)();
  
    Test_Fish* fish = OOC_ONAME(OOC_CTOR_NAME(Test_Fish), a)("小鲤鱼", 1);
    Test_Dog* dog = OOC_ONAME(OOC_CTOR_NAME(Test_Dog), a)("牧羊犬", 2);
    Test_Car* car = OOC_CTOR_NAME(Test_Car)();
    
      
     
    //------------多态测试输出-------------------------------------------------------
    Test_Animal* animals[] = {fish->Animal, dog->Animal};
    
    printf("\n多态测试输出：\n");
    for(int i = 0; i < sizeof(animals) / sizeof(animals[0]); i++){
        printf("animals[%d].toString(): %s\n", i,  (muc8*)animals[i]->toString(animals[i]));
        animals[i]->eat(animals[i]);
        animals[i]->breathe(animals[i]);
    }
    
    //-----------接口测试输出--------------------------------------------------------------------
    Test_IMoveable* moveables[] = {&fish->IMoveable, &dog->IMoveable, &car->IMoveable};
    
    printf("\n 接口测试输出：\n");
    for(int i = 0; i < sizeof(moveables) / sizeof(moveables[0]); i++){
        moveables[i]->move(moveables[i]);
    }    
    
    
    //-----------类型运行时验证测试输出---------------------------------------------------------------
  
    printf("\n类型运行时验证测试输出：\n");
    printf("Obj is Object ?[%s]\n"
            "Obj is Fish ?[%s]\n"
            "Obj is Animal?[%s]\n\n",
            ObjectClass.instanceof(obj, "Object") == MTRUE ? "true" : "false", 
            ObjectClass.instanceof(obj, "Fish") == MTRUE ? "true" : "false",
            ObjectClass.instanceof(obj, "Animal") == MTRUE ? "true" : "false");    
    
    printf("Fish is Object ?[%s]\n"
            "Fish is Fish ?[%s]\n"
            "Fish is Animal?[%s]\n\n",
            ObjectClass.instanceof(fish, "Object") == MTRUE ? "true" : "false", 
            ObjectClass.instanceof(fish, "Fish") == MTRUE ? "true" : "false",
            ObjectClass.instanceof(fish, "Animal") == MTRUE ? "true" : "false");
 
    
    
 
    ObjectClass.release(fish);
    ObjectClass.release(dog);
    
    ObjectClass.release(obj);
    ObjectClass.release(car);    
#if OOC_CFG_SW_DEBUG == OOC_SWITCH_ON
    ObjectClass.tDbg.tMLeak.report(MLEAK_REPORT_LEVEL_BRIEF);
    
#endif

    
    
    
    
    
    return 0;
}
